package servlet;

import mapper.StudentMapper;
import pojo.Student;
import utils.MybatisUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author leiHua
 * @Date 2022/11/24 18:34
 */
@WebServlet("/findStudentBynumServlet")
public class FindStudent extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String num = request.getParameter("num");
        StudentMapper mapper = MybatisUtils.getSqlSession().getMapper(StudentMapper.class);
        Student student = mapper.selectStudentByNum(num);
        request.setAttribute("student",student);
        request.getRequestDispatcher("/updateStudent.jsp").forward(request,response);
    }
}
